<?php 
	include '../ini.php';
	include '../includes/function.php';
	include '../libraries/xl_phuong_thuc_thanh_toan.php'; 
	$dt_xl_phuong_thuc_thanh_toan = new xl_phuong_thuc_thanh_toan;
	include "../libraries/xl_thanh_vien.php";
	$dt_xl_thanh_vien = new xl_thanh_vien;
	
	 if(count($_SESSION['gio_hang']) <=0) {
		$_SESSION['msg'] = 'Lỗi! Giỏ hàng của Bạn chưa có sản phẩm. Bạn hãy chọn mua hàng để tiếp tục!';
		$_SESSION['type_msg'] = 'error';
		header('Location: ../home/trang-chu.html');
		exit;
	 }	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<?php include '../widgets/head.php'?>
</head>
<body>
<div id="art-page-background-glare">
  <div id="art-page-background-glare-image">
    <div id="art-main">
      <div class="art-sheet">
        <div class="art-sheet-tl"></div>
        <div class="art-sheet-tr"></div>
        <div class="art-sheet-bl"></div>
        <div class="art-sheet-br"></div>
        <div class="art-sheet-tc"></div>
        <div class="art-sheet-bc"></div>
        <div class="art-sheet-cl"></div>
        <div class="art-sheet-cr"></div>
        <div class="art-sheet-cc"></div>
        <div class="art-sheet-body">
          <?php include '../widgets/header.php'?>
          <?php include '../widgets/nav.php'?>
          <div class="art-content-layout">
            <div class="art-content-layout-row">
              <div class="art-layout-cell art-sidebar1">
                <?php sidebar('left');?>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-content">
                <div class="art-post">
                  <div class="art-post-tl"></div>
                  <div class="art-post-tr"></div>
                  <div class="art-post-bl"></div>
                  <div class="art-post-br"></div>
                  <div class="art-post-tc"></div>
                  <div class="art-post-bc"></div>
                  <div class="art-post-cl"></div>
                  <div class="art-post-cr"></div>
                  <div class="art-post-cc"></div>
                  <div class="art-post-body">
                    <div class="art-post-inner art-article">
                      <?php thong_bao();?>
                      <h2 class="art-postheader">Giỏ hàng của bạn</h2>
                      <div class="line"> </div>
                      <div class="art-postcontent">
                        <table class="gio_hang">
                          <tr>
                            <th class="stt">STT</th>
                            <th class="ten_sp">Tên sách</th>
                            <th class="so_luong">Số lượng</th>
                            <th class="don_gia">Đơn giá (VNĐ)</th>
                            <th class="thanh_tien">Thành tiền (VNĐ)</th>
                          </tr>
                          <?php
								$stt = 0;
								$tong_tien = 0;
								foreach($_SESSION['gio_hang'] as $k=>$v) 
								{
									$stt++;
							  ?>
                          <tr>
                            <td class="stt"><?php echo $stt?></td>
                            <td class="ten_sp"><?php echo $v['ten']?></td>
                            <td class="so_luong so"><?php echo $v['so_luong']?></td>
                            <td class="don_gia so"><?php echo number_format($v['don_gia'],2,'.',',')?></td>
                            <td class="thanh_tien so"><?php echo number_format($v['thanh_tien'],2,'.',','); $tong_tien += $v['thanh_tien'];?></td>
                          </tr>
                          <?php
								}
							  ?>
                          <tr>
                            <td colspan="6" class="tong_tien">Tổng tiền: <?php echo number_format($tong_tien,2,'.',',');?> VNĐ </td>
                        </table>
                      </div>
                      <div class="cleared"></div>
                    </div>
                    <script language="javascript">
						function CopyPaste()
						{
							var f = document.dat_hang;
							document.getElementById('ho_ten_nguoi_nhan').value = f.ho_ten.value;
							document.getElementById('dien_thoai_nguoi_nhan').value = f.dien_thoai.value;
							document.getElementById('dia_chi_nguoi_nhan').value = f.dia_chi.value;
							document.getElementById('cmnd_nguoi_nhan').value = f.cmnd.value;
						}
                    </script> 
                    <!--form_dang_nhap-->
                    <style>
						fieldset { padding:0; border:0; margin-top:25px; }
						div#users-contain { width: 350px; margin: 20px 0; }
						div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
						div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
						.ui-dialog .ui-state-error { padding: .3em; }
						.validateTips { border: 1px solid transparent; padding: 0.3em; }
					</style>
                    <script>
						$(function() {
							$( "#form_dang_nhap" ).dialog({
								autoOpen: false,
								height: 280,
								width: 338,
								modal: true,
								close: function() {
									allFields.val( "" ).removeClass( "ui-state-error" );
								}
							});
						
							$( "#mo_form" )
								.button()
								.click(function() {
									$( "#form_dang_nhap" ).dialog( "open" );
								});
						
							$( "#dang_nhap" )
								.button();
						
							$( "#huy" )
								.button()
								.click(function() {
									$( "#form_dang_nhap" ).dialog( "close" );
								});
						});
					  </script>
                    <form id="form_dang_nhap" action="../thanh-vien/dang-nhap.html" method="post">
                      <table style="margin:10px; font-size:18px">
                        <tr>
                          <td>Tên đăng nhập:</td>
                          <td><input type="text" value="<?php echo $_COOKIE['ten_dang_nhap_ghi_nho'];?>" name="ten_dang_nhap" id="ten_dang_nhap" class="text ui-widget-content ui-corner-all" /></td>
                        </tr style="height:50px">
                        <tr height="50px">
                          <td>Mật khẩu:</td>
                          <td><input type="password" value="<?php echo base64_decode(base64_decode(base64_decode($_COOKIE['mat_khau_ghi_nho'])));?>" name="mat_khau" id="mat_khau" class="text ui-widget-content ui-corner-all" /></td>
                        </tr>
                        <tr>
                          <td colspan="2" align="center"><input style="margin-bottom:4px" <?php if($_COOKIE['ghi_nho']=='true') echo 'checked="checked"'?> type="checkbox" name="ghi_nho" />
                            Ghi nhớ mật khẩu</td>
                        </tr>
                        <tr height="50px">
                          <td colspan="2" align="center"><a href="../thanh-vien/quen-mat-khau.html">Quên mật khẩu</a>
                        </tr>
                        <tr>
                          <td colspan="2" align="center"><input id="dang_nhap" class="dang_nhap ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" name="dang_nhap" value="Đăng nhập" />
                            <input id="huy" class="dang_nhap ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" name="huy" value="Hủy" /></td>
                        </tr>
                      </table>
                    </form>
                    <!--end dang nhap -->
                    <form name="dat_hang" action="../dat-hang/xu-ly-don-dat-hang.html" method="post">
                      <br />
                      <div class="art-post-inner art-article">
                        <h2 class="art-postheader">Thông tin thanh toán</h2>
                        <?php if($_SESSION[SALT_USER.'_LOGIN']==''){?>
                        <p style="color:red">Nếu Bạn là thành viên hãy đăng nhập để thanh toán.</p>
                        <br />
                        <p>
                        <div id="mo_form">Đăng nhập</div>
                        </p>
                        <br />
                        <?php }?>
                        <div class="line"> </div>
                        <table cellspacing="0" cellpadding="0" class="thanhtoan">
                          <tr>
                            <th colspan="2" class="thong_tin">THÔNG TIN NGƯỜI MUA</th>
                          </tr>
                          <?php 
							if($_SESSION[SALT_USER.'_LOGIN']=='OK') 
							{
								$thanh_vien=$dt_xl_thanh_vien->xem_ten_dn($_SESSION['TEN_DANG_NHAP_USER']);
								$nam=substr($thanh_vien['ngay_sinh'],0,4);
								$thang=substr($thanh_vien['ngay_sinh'],5,2);
								$ngay=substr($thanh_vien['ngay_sinh'],8,2);
								$ngay_sinh=$thang.'/'.$ngay.'/'.$nam;
							?>
                          <tr>
                            <td class="l">Họ và Tên:</td>
                            <td style="width:440px" class="r"><input type="text" value="<?php echo $thanh_vien['ho_ten'];?>" name="ho_ten" id="ho_ten" class="dai">
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Số CMND:</td>
                            <td class="r"><input type="text" name="cmnd" id="cmnd" value="<?php echo $thanh_vien['cmnd'];?>" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Giới tính:</td>
                            <td style="text-align: left ! important; padding-left: 0px ! important;" class="r"><input <?php  if($thanh_vien['gioi_tinh']==0) echo 'checked="checked"';?> type="radio" checked="checked" value="0" name="gioi_tinh" class="radio">
                              <span style="vertical-align: middle;">Nam</span>
                              <input value="1" <?php  if($thanh_vien['gioi_tinh']==1) echo 'checked="checked"';?> type="radio" name="gioi_tinh" class="radio">
                              <span style="vertical-align: middle;">Nữ</span></td>
                          </tr>
                          <tr>
                            <td class="l">Ngày sinh:</td>
                            <td class="r"><script>
										$(function() {
											$( "#ngay_sinh" ).datepicker();
										});
									</script>
                              <input type="text" id="ngay_sinh" value="<?php echo $ngay_sinh;?>" name="ngay_sinh">
                              <small style="color:red">Nhập vào dạng ngày tháng MM/DD/YYYY</small>
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Địa chỉ:</td>
                            <td class="r"><input type="text" name="dia_chi" id="dia_chi" value="<?php echo $thanh_vien['dia_chi'];?>" class="dai">
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Email:</td>
                            <td class="r"><input type="text" name="email" value="<?php echo $thanh_vien['email'];?>" class="dai">
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Điện thoại:</td>
                            <td class="r"><input type="text" value="<?php echo $thanh_vien['dien_thoai'];?>" name="dien_thoai" id="dien_thoai" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <?php }else {?>
                          <tr>
                            <td class="l">Họ và Tên:</td>
                            <td style="width:440px" class="r"><input type="text" value="<?php echo $_SESSION['ho_ten']; $_SESSION['ho_ten']=''?>" name="ho_ten" id="ho_ten" class="dai">
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Số CMND:</td>
                            <td class="r"><input type="text" name="cmnd" id="cmnd" value="<?php echo $_SESSION['cmnd']; $_SESSION['cmnd']=''?>" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Giới tính:</td>
                            <td style="text-align: left ! important; padding-left: 0px ! important;" class="r"><input type="radio" checked="checked" value="0" name="gioi_tinh" class="radio">
                              <span style="vertical-align: middle;">Nam</span>
                              <input value="1" type="radio" name="gioi_tinh" class="radio">
                              <span style="vertical-align: middle;">Nữ</span></td>
                          </tr>
                          <tr>
                            <td class="l">Ngày sinh:</td>
                            <td class="r"><script>
										$(function() {
											$( "#ngay_sinh" ).datepicker();
										});
									</script>
                              <input type="text" id="ngay_sinh" value="<?php echo $_SESSION['ngay_sinh']; $_SESSION['ngay_sinh']=''?>" name="ngay_sinh">
                              <small style="color:red">Nhập vào dạng ngày tháng MM/DD/YYYY</small>
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Địa chỉ:</td>
                            <td class="r"><input type="text" name="dia_chi" id="dia_chi" value="<?php echo $_SESSION['dia_chi']; $_SESSION['dia_chi']=''?>" class="dai">
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Email:</td>
                            <td class="r"><input type="text" name="email" value="<?php echo $_SESSION['email']; $_SESSION['email']=''?>" class="dai">
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Điện thoại:</td>
                            <td class="r"><input type="text" value="<?php echo $_SESSION['dien_thoai']; $_SESSION['dien_thoai']=''?>" name="dien_thoai" id="dien_thoai" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <?php }?>
                          <tr>
                            <td class="l">Yêu cầu khác:</td>
                            <td class="r"><textarea style="width: 403px ! important;" value="<?php echo $_SESSION['ghi_chu']; $_SESSION['ghi_chu']=''?>" name="ghi_chu" class="dai"></textarea></td>
                          </tr>
                          <tr>
                            <td style="color: #00F; height: 45px ! important; vertical-align: middle; text-align: center;" colspan="2">Nếu người mua cũng là người nhận: <span class="art-button-wrapper"> <span class="art-button-l"> </span> <span class="art-button-r"> </span>
                              <input type="button" onclick="CopyPaste();" value="Click vào đây" class="art-button">
                              </span></td>
                          </tr>
                          <tr>
                            <th colspan="2" class="thong_tin">THÔNG TIN NGƯỜI NHẬN</th>
                          </tr>
                          <tr>
                            <td class="l">Họ và Tên:</td>
                            <td class="r"><input type="text" value="<?php echo $_SESSION['ho_ten_nguoi_nhan']; $_SESSION['ho_ten_nguoi_nhan']=''?>" id="ho_ten_nguoi_nhan" name="ho_ten_nguoi_nhan" class="dai" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <!--<tr>
                              <td class="l">Số CMND:</td>
                              <td class="r"><input type="text" name="cmnd_nguoi_nhan" id="cmnd_nguoi_nhan" value="<?php echo $_SESSION['cmnd_nguoi_nhan']; $_SESSION['cmnd_nguoi_nhan']=''?>" >
                                <span style="color:red; float:right"> (*)</span></td>
                            </tr>-->
                          <tr>
                            <td class="l">Địa chỉ:</td>
                            <td class="r"><input class="dai" type="text" value="<?php echo $_SESSION['dia_chi_nguoi_nhan']; $_SESSION['dia_chi_nguoi_nhan']=''?>" id="dia_chi_nguoi_nhan" name="dia_chi_nguoi_nhan" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Điện thoại:</td>
                            <td class="r"><input type="text" value="<?php echo $_SESSION['dien_thoai_nguoi_nhan']; $_SESSION['dien_thoai_nguoi_nhan']=''?>" id="dien_thoai_nguoi_nhan" name="dien_thoai_nguoi_nhan" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td class="l">Mã bảo vệ</td>
                            <td class="r"><script language="javascript">
									function doi_hinh_thanh_toan() {
										var x = '../includes/randompic.php?a=' + Math.random();
										document.getElementById('hinh_bao_ve_thanh_toan').src = x;
									}
								</script> 
                              <img src="../includes/randompic.php" style="margin: 0pt; padding: 0pt; vertical-align: middle;" id="hinh_bao_ve_thanh_toan"> <span onclick="doi_hinh_thanh_toan()" style="color: blue; cursor: pointer; vertical-align: middle;">Đổi ảnh khác</span></td>
                          </tr>
                          <tr>
                            <td class="l">Nhập mã bảo vệ:</td>
                            <td class="r"><input type="text" name="ma_bao_ve" >
                              <span style="color:red; float:right"> (*)</span></td>
                          </tr>
                          <tr>
                            <td style="text-align:center; padding:10px" colspan="2">
                            <small style="color:red"><em>(Chú ý: chỉ giao hàng ở Thành Phố Hồ Chí Minh và hoàn toàn miễn phí)</em><br /><br /></small><span class="art-button-wrapper"> <span class="art-button-l"> </span> <span class="art-button-r"> </span>
                              <input type="submit" value="Đặt hàng" class="art-button">
                              </span> <span class="art-button-wrapper"> <span class="art-button-l"> </span> <span class="art-button-r"> </span> </span></td>
                          </tr>
                        </table>
                      </div>
                    </form>
                    <div class="cleared"></div>
                  </div>
                </div>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-sidebar2">
                <?php sidebar('right')?>
                <div class="cleared"></div>
              </div>
            </div>
          </div>
          <div class="cleared"></div>
          <?php include '../widgets/footer.php'?>
          <div class="cleared"></div>
        </div>
      </div>
      <div class="cleared"></div>
    </div>
  </div>
</div>
</body>
</html>
